<?php
namespace Tbf\Component\Crypto\Password\Plan;
use Tbf\Component\Crypto\Password\PlanInterface;
use Tbf\Component\Strings\StringFunction;
/**
* 简单md5hex
* 非常不安全,不要用于加密已有密码
* 密码格式
* 原文a123456 $md5hex$dc483e80a7a0bd9ef71d8cf973673924$
*/
class Md5HexPlan implements PlanInterface
{
    public function hash($plain)
    {
        return '$md5hex$'.md5($plain).'$';
    }
    public function verify($plain,$hashed)
    {
        $data = explode('$',$hashed);

        return md5($plain)==$data[2];
    }
    public function support($hashed)
    {
        if (StringFunction::startWith($hashed,'$md5hex$')) {
            return true;
        }

        return false;
    }
}
